package com.cmhi.base.provider;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import com.softmbh.kellyplatform.util.AppUtils;

public class BimDBHelper extends SQLiteOpenHelper {

    private static final String DB_NAME = "authentication.db";
    public static final String HUA_WEI_TABLE_NAME = "authentication";
    public static final String SHARE_INFO_TABLE_NAME = "shareinfo";
    private static final int DB_VERSION = 2;


    public static final String HUA_WEI_COLUMNS_NAME = "name";
    public static final String HUA_WEI_COLUMNS_VALUE = "value";
    public static final String SHARE_INFO_COLUMNS_NAME = "sharekey";
    public static final String SHARE_INFO_COLUMNS_VALUE = "value";

    private String CREATE_HUA_WEI_TABLE = "CREATE TABLE " + HUA_WEI_TABLE_NAME + " ("
            + HUA_WEI_COLUMNS_NAME + " TEXT,"
            + HUA_WEI_COLUMNS_VALUE + " TEXT"
            + ");";
    private String CREATE_SHARE_INFO_TABLE = "CREATE TABLE " + SHARE_INFO_TABLE_NAME + " ("
            + SHARE_INFO_COLUMNS_NAME + " TEXT,"
            + SHARE_INFO_COLUMNS_VALUE + " TEXT"
            + ");";

    public BimDBHelper(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        AppUtils.debugLog( "onCreate");
        db.execSQL(CREATE_HUA_WEI_TABLE);
        db.execSQL(CREATE_SHARE_INFO_TABLE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        AppUtils.debugLog( "onUpgrade");
        db.execSQL("DROP TABLE IF EXISTS " + HUA_WEI_TABLE_NAME);
        db.execSQL("DROP TABLE IF EXISTS " + SHARE_INFO_TABLE_NAME);
        onCreate(db);
    }
}
